'''
Created on Apr 28, 2012
TC ID: Ecom_5030
Desc: Kiem thu chuc nang tim kiem mot thong bao
@author: lavang
'''
import unittest

from HTMLTestRunner import HTMLTestRunner
import time
from Functions.globalFunc import readData, preCondition, endCondition
from Functions.loginPageFunc import login
from Functions.announcementFunc import clickOnGoToAnnouncement,\
     searchAnnouncement,\
    isAnnouncementExist

username=readData("username")
password=readData("password")
tm_announcementName='announcement30_04'

class Ecom_5030(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5027(self):
        print "Buoc 1: Dang nhap vao website"
        login(self,username,password)
        
        print "Buoc 2: Click 'Go to announcement page' "
        clickOnGoToAnnouncement(self)
        
        print "Buoc 3: Tim kiem thong bao "
        searchAnnouncement(self,tm_announcementName)
    
        print "Buoc 4: Xac nhan thong bao duoc tim thay"
        self.assertTrue(isAnnouncementExist(self,tm_announcementName), "Failed!")
        print "Passed! Thong bao duoc tim thay"
    
    def tearDown(self):
        endCondition(self)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5030)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang tim kiem mot thong bao'
                    )
    runner.run(suite)